﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Drawing;
using System.ComponentModel;

namespace OpenChart.Entities
{
    public class ChartArea:ChartElement
    {
        #region 公共属性

        /// <summary>
        /// 要显示的数据
        /// </summary>
        public DataTable Data { get; set; }

        /// <summary>
        /// X轴数据名称
        /// </summary>
        public string XValueMember { get; set; }

        private List<Series> _series = new List<Series>();
        /// <summary>
        /// Series 列表
        /// </summary>
        [Bindable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]  
        public List<Series> Series
        {
            get { return _series; }
            set { _series = value; }
        }

        private List<PartingLine> _partingLines = new List<PartingLine>();
        /// <summary>
        /// 分割线
        /// </summary>
        [Bindable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]  
        public List<PartingLine> PartingLines
        {
            set { _partingLines = value; }
            get { return _partingLines; }
        }

        private StringInfo _chartTitle = new StringInfo();
        /// <summary>
        /// 图表标题
        /// </summary>
        public StringInfo ChartTitle
        {
            get { return _chartTitle; }
            set { _chartTitle = value; }
        }

        private Axis _axisX = new Axis();
        /// <summary>
        /// 横坐标
        /// </summary>
        public Axis AxisX
        {
            get { return _axisX; }
            set { _axisX = value; }
        }

        private Axis _axisY1 = new Axis();
        /// <summary>
        /// 第一个纵坐标
        /// </summary>
        public Axis AxisY1
        {
            get { return _axisY1; }
            set { _axisY1 = value; }
        }

        private Axis _axisY2 = new Axis();
        /// <summary>
        /// 第二个纵坐标
        /// </summary>
        public Axis AxisY2
        {
            get { return _axisY2; }
            set { _axisY2 = value; }
        }

        private int _axisLineWidth = 1;
        /// <summary>
        /// 坐标轴线宽度
        /// </summary>
        public int AxisLineWidth
        {
            get { return _axisLineWidth; }
            set { _axisLineWidth = value; }
        }

        private Color _axisLineColor = Color.Black;
        /// <summary>
        /// 坐标轴线颜色
        /// </summary>
        public Color AxisLineColor
        {
            get { return _axisLineColor; }
            set { _axisLineColor = value; }
        }

        private Enums.ChartType _chartType = Enums.ChartType.Line;
        /// <summary>
        /// 图表类型
        /// </summary>
        public Enums.ChartType ChartType
        {
            get { return _chartType; }
            set { _chartType = value; }
        }

        private int _baseNumber = 10;
        /// <summary>
        /// 对数的底,目前不支持小数底（仅当属性ChartType设置为LogLine、LogArea时起作用）
        /// </summary>
        public int BaseNumber
        {
            get { return _baseNumber; }
            set
            {
                if (value <= 0 || value == 1)
                {
                    throw new Exception("对数的底只能是大于0且不等于1的数");
                }
                if (value < 1)
                {
                    throw new Exception("底小于1的对数函数是单调递减的，用来画折线图不合适");
                }
                _baseNumber = value;
            }
        }

        #endregion
    }
}
